    # init {{{
    set previewer "~/.config/lf/previewer"
    set incsearch
    set findlen 0
    set noanchorfind
    set ifs "\n"
    set info "size"
    set promptfmt "%w/%f"
    source "~/.config/shortcuts/lf"
    set number
    set icons
    set relativenumber
    set hidden true
    # unmap default binding that confilict with mine {{{
    map k
    map j
    map h
    map l
    map v
    map u
    map y
    map d
    map p
    map c
    map z
    map s
    map i
    map e
    map w
    map "'"
    map <f-1>
    # }}}
    # }}}

    # functions {{{
    # open
    cmd open ${{
    	bgopen(){ setsid "$@">/dev/null 2>&1 & }
    	open() {
    		case $(file --mime-type -Lb "$@") in
    			video/*                  ) vlc "$fx";;
    			audio/*                  ) mpv "$fx";;
    			text/*|application/json  ) nvim "$fx";;
    			image/gif                ) bgopen sxiv -ba "$fx";;
    			image/*                  ) bgopen sxiv -b "$fx";;
    			application/pdf|application/epub+zip|application/x-rar) zathura "$fx";;
    			application/pgp-signature) nvim "$fx";;
    			inode/symlink            ) open "$(readlink -f $fx)";;
    			*) for f in $fx; do $OPENER $f>/dev/null 2>&1 & done;;
    		esac
    	}
    	open "$f"
    }}

    # extract
    cmd extract ${{
    	case "$f" in
    		*.tar.bz2|*.tar.xz|*.tbz2) tar xvf "$f" ;;
    		*.tar.gz|*.tgz) tar xzvf "$f";;
    		*.zip) unzip "$f";;
    		*.rar) unrar x "$f";;
    		*.7z) 7z x "$f";;
    		*.lzma) unlzma "$f" ;;
    		*.bz2) bunzip2 "$f" ;;
    		*.gz) gunzip "$f" ;;
    		*.tar) tar xvf "$f" ;;
    		*.Z) uncompress "$f" ;;
    		*.xz) unxz "$f" ;;
    		*.exe) cabextract "$f" ;;
    	esac
    }}

    # trash!!!
    cmd trash %{{
    	set -f

    	if [ command -v trash ]; then
    		echo "Please install transh-cli in order to use this."
    	else
    		printf "$fx\n"
    		printf "delete?[y/n]"

    		read ans
    		[ $ans = "y" ] && trash $fx
    	fi
    }}

    # chmod
    cmd chmod %{{
    	chmod "$1" $fx
    	lf -remote "send load"
    	lf -remote "send unselect"
    	lf -remote "send clear"
    	lf -remote "send reload"
    }}

    cmd bulk-rename ${{
        old=$(mktemp)
        new=$(mktemp)
        [ -n $fs ] && fs=$(ls)
        printf "$fs\n" > $old
        printf "$fs\n" > $new
        $EDITOR $new
        [ $(cat $new | wc -l) -ne $(cat $old | wc -l) ] && exit
        paste $old $new | while read names; do
            src=$(printf $names | cut -f1)
            dst=$(printf $names | cut -f2)
            [ $src = $dst ] && continue
            [ -e $dst ] && continue
            mv $src $dst
        done
        rm $old $new
        lf -remote "send $id unselect"
    }}
    # }}}

    cmd setbg "$1"
    
    # fzf
    cmd open-with $"$@" "$fx"

    # bindings {{{
    # movement
    map h updir
    map j down
    map k up
    map l open
    map <a-j> half-down
    map <a-k> half-up

    # cmd movement
    cmap <a-h> cmd-left
    cmap <a-j> cmd-history-next
    cmap <a-k> cmd-history-prev
    cmap <a-l> cmd-right
    cmap <down> cmd-history-next
    cmap <up> cmd-history-prev

    # file util
    map ] copy
    map t cut
    map p paste
    map <a-t> trash
    map T delete
    map <esc> :unselect; clear;

    # renameing
    map cc push A<c-u>
    map I push A<c-a>
    map A rename
    map i push A<a-b><c-b>
    map a push A<a-b>

    # etc
    map <a-i> set hidden!
    map r push :open-with<space>
    map , extract
    map <a-f> $fzf | xargs -r nvim
    map <a-r> reload
    map u $du -hd1 2>/dev/null | sort -rh | "${PAGER:-less}"
    map f quit
    # }}}


